package com.lantosec.hmrp.modules.sysdata.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.lantosec.hmrp.core.mvc.BaseEntity;
import com.lantosec.hmrp.modules.sysdata.vo.SysDataModelVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * <p>
 * 系统数据模型定义表 实体类
 * </p>
 *
 * @author AutoCode
 * @since 2020-03-02
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SysDataModel extends BaseEntity<SysDataModelVO> {

    private static final long serialVersionUID = 1L;
    /**
     * 数据模型ID
     */
    @TableId(value = "data_model_id", type = IdType.ASSIGN_UUID)
    private String dataModelId;
    /**
     * 数据模型名称
     */
    private String dataModelName;
    /**
     * 数据库名
     */
    private String databaseName;
    /**
     * 表名
     */
    private String tableName;
    /**
     * 对应的服务类名
     */
    private String serviceName;
    /**
     * 创建时间
     */
    private Date createTime;
    /**
     * 最后编辑时间
     */
    private Date editTime;

    public SysDataModel(SysDataModelVO vo) {
        this.dataModelId = vo.getDataModelId();
        this.dataModelName = vo.getDataModelName();
        this.databaseName = vo.getDatabaseName();
        this.tableName = vo.getTableName();
        this.serviceName = vo.getServiceName();
        this.createTime = vo.getCreateTime();
        this.editTime = vo.getEditTime();
    }

    @Override
    public SysDataModelVO convertToVO() {
        return new SysDataModelVO(this);
    }


    public enum ColName {
        data_model_id, data_model_name, database_name, table_name, service_name, create_time, edit_time,
    }
}
